<?php
namespace app\admin\model;

use think\Controller;
use think\Db;

#公共操作#
class ComModel extends Controller{

	public $success="数据添加成功~";
	public $error ="数据添加失败，请重试~";

	#数据添加#
	public function data_add($dbname,$data,$url=''){
		
		$r=Db::name($dbname)->insert($data);
		
		if($r == true){
			$this->success("数据添加成功~",$url);
		}else{
			$this->error("数据添加失败，请重试~",$url);
		}

	}

	#数据修改#
	public function data_up($dbname,$data,$url='',$where=''){

		$r=Db::name($dbname)->where($where)->update($data);
		
		if($r == true){
			$this->success("数据修改成功~",$url);
		}else{
			$this->error("数据修改失败，请重试~",$url);
		}
	}

	#数据查找#
	public function data_find($dbname,$where=''){

		return Db::name($dbname)->where($where)->find();
		
	}
	#数据删除#
	public function data_del($dbname,$where){

		return Db::name($dbname)->where($where)->delete();
		
	}


}